]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add gnome-shell --eval-file
authorColin Walters <walters@verbum.org>
Thu, 12 Nov 2009 23:18:34 +0000 (18:18 -0500)
committerColin Walters <walters@verbum.org>
Fri, 13 Nov 2009 17:45:46 +0000 (12:45 -0500)
Convenience utility function for evaluating an arbitrary
JavaScript file.

src/gnome-shell.in

index 2acc967ed0d074e85c96d9e6b88b6605ff1a1535..e5ef5095e8c681ff13b45633c6305676f16a345c 100644 (file)
@@ -212,6 +212,8 @@ parser.add_option("", "--geometry", metavar="GEOMETRY",
                   default="1024x768");
 parser.add_option("-w", "--wide", action="store_true",
                   help="Use widescreen (1280x800) with Xephyr")
+parser.add_option("", "--eval-file", metavar="EVAL_FILE",
+                  help="Evaluate the contents of the given JavaScript file")
 
 options, args = parser.parse_args()
 
@@ -219,6 +221,20 @@ if args:
     parser.print_usage()
     sys.exit(1)
 
+if options.eval_file:
+    import dbus
+
+    f = open(options.eval_file)
+    contents = f.read()
+    f.close()
+
+    session = dbus.SessionBus()
+    shell = session.get_object('org.gnome.Shell', '/org/gnome/Shell')
+    shell = dbus.Interface(shell, 'org.gnome.Shell')
+    result = shell.Eval(contents)
+    print result
+    sys.exit(0)
+
 if options.debug_command:
     options.debug = True
 elif options.debug: